<template>
  <div @click="$router.push('/details/'+postData.id)">
    <!-- 显示内容 -->
    <!-- 纯新闻+少于3张图片 -->
    <!-- 大于3张图片 -->
    <!-- 视频 -->
    <!-- 单图 -->
    <div class="bill" v-if="postData.type==1&&postData.cover.length>=1&&postData.cover.length<3">
      <div class="left">
        <div class="title">{{postData.title}}</div>
        <div class="nickname">{{postData.user.nickname}} {{postData.comment_length}}回帖</div>
      </div>
      <div class="right">
        <img :src="postData.cover[0].url | fixImgUrl" alt />
      </div>
    </div>
    <!-- 多图 -->
    <div class="much" v-if="postData.type==1&&postData.cover.length>=3">
      <div class="top">{{postData.title}}</div>
      <div class="imgs">
        <img :src="postData.cover[0].url | fixImgUrl" alt />
        <img :src="postData.cover[1].url | fixImgUrl" alt />
        <img :src="postData.cover[2].url | fixImgUrl" alt />
      </div>
      <div class="nickname">{{postData.user.nickname}} {{postData.comment_length}}回帖</div>
    </div>
    <!-- 视频 -->
    <div class="video" v-if="postData.type==2&&postData.cover.length>=1">
      <div class="top">{{postData.title}}</div>
      <div class="imgs">
        <img :src="postData.cover[0].url | fixImgUrl" alt />
        <div class="icfont">
          <span class="iconfont iconshipin"></span>
        </div>
      </div>
      <div class="nickname">{{postData.user.nickname}}☆☆☆ {{postData.comment_length}}回帖</div>
    </div>
  </div>
</template>

<script>
export default {
  props: ["postData"],
  data() {
    return {};
  },

  mounted() {
    console.log("postitem");
    console.log(this.postData);
  }
};
</script>

<style lang="less" scoped>
//单图
.bill {
  display: flex;
  box-sizing: border-box;
  width: 100vw;
  height: 22.222vw;
  padding: 1.667vw 3.333vw;
  border-bottom: 1px solid #ccc;
  .left {
    flex: 1;
    .title {
      font-size: 4.444vw;
    }
    //昵称
    .nickname {
      margin-top: 1.111vw;
      font-size: 3.889vw;
      color: #888;
    }
  }
  .right {
    //图片
    img {
      width: 31.111vw;
      height: 18.333vw;
    }
  }
}
//多图
.much {
  box-sizing: border-box;
  padding: 1.667vw 1.667vw;
  border-bottom: 1px solid #ccc;
  //标题
  .top {
    font-size: 4.444vw;
    margin-bottom: 1.667vw;
  }
  //图片
  .imgs {
    display: flex;
    justify-content: space-around;
    img {
      width: 31.111vw;
      height: 18.333vw;
    }
  }
  //昵称
  .nickname {
    margin-top: 2.222vw;
    font-size: 3.889vw;
    color: #888;
  }
}
//视频
.video {
  position: relative;
  box-sizing: border-box;
  padding: 2.778vw 2.778vw;
  border-bottom: 1px solid #ccc;
  //上边标题
  .top {
    font-size: 4.444vw;
    margin-bottom: 1.667vw;
  }
  //图片
  .imgs {
    display: flex;
    justify-content: center;
    align-items: center;
    img {
      width: 100%;
      height: 47.222vw;
      object-fit: cover;
    }
    //暂停的字体图标
    .icfont {
      .iconshipin {
        position: absolute;
        top: 36vw;
        right: 47.222vw;
        width: 10.556vw;
        height: 10.556vw;
        line-height: 10.556vw;
        font-size: 11.111vw;
        color: #fff;
        border-radius: 50%;
        background: #ccc;
      }
    }
  }
  //昵称
  .nickname {
    margin-top: 2.222vw;
    font-size: 3.889vw;
    color: #888;
  }
}
</style>